import datetime

import jwt
import base64
import json
from base64 import urlsafe_b64decode

# JWT token
token =("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjozMDkzNCwicmVhbF9uYW1lIjoi5YiY6ZmGIiwicGhvbmUiOiIxNzYyMTQ1NTE5OCIsImRpYWxsaW5nX2NvZGUiOiI4NiIsInBsYXRmb3JtIjoxLCJyYW5kX251bSI6MTczMTEzNzY0MCwiZXhwIjoxNzMxMjI0MDQwLCJpc3MiOiJnaW4tYmxvZyJ9.o0xOAsS05NmhjglXvQP4vnxFBog8Wkeu7f9trlM-BXw")

# 分割JWT token, 获取头部、负载和签名(token格式为: 头部header.负载body.签名signature)
header, payload, signature = token.split('.')

# 解码Base64Url编码的头部和负载
decoded_header = json.loads(urlsafe_b64decode(header))
decoded_payload = json.loads(urlsafe_b64decode(payload))

print("Decoded Header:", decoded_header)
print("Decoded Payload:", decoded_payload)


timestamp = 1721180092
date_01 = datetime.datetime.fromtimestamp(timestamp)
print(date_01)